//
//  WJYRadioTableViewCell.m
//  WWLNetease
//
//  Created by dllo on 15/12/28.
//  Copyright © 2015年 Echo.Jobs. All rights reserved.
//

#import "WJYRadioTableViewCell.h"

@interface WJYRadioTableViewCell()<UICollectionViewDataSource, UICollectionViewDelegate>

@end

@implementation WJYRadioTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCollectView];
    }
    return self;
}

#pragma mark --- 创建CollectionView
- (void)createCollectView
{
    
    // collectionView子方法
    UICollectionViewFlowLayout *flowL = [[UICollectionViewFlowLayout alloc] init] ;
    
    // 滚动方向
    flowL.scrollDirection = UICollectionViewScrollDirectionVertical;
    flowL.itemSize = CGSizeMake((self.frame.size.width - 10) * KPropotionWidth / 3, 160 * SIZE );
    
    // 上左下右
    flowL.sectionInset = UIEdgeInsetsMake(15, 10, 10, 10);
    flowL.minimumLineSpacing = 0;
    
    
    // CollectionView方法
    self.collectView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 375, self.frame.size.height) collectionViewLayout:flowL];
    
    
    [self addSubview:self.collectView];
    [self.collectView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    

    
    // 背景颜色
    self.collectView.backgroundColor = [UIColor colorWithRed:0.000 green:0.694 blue:1.000 alpha:1.000];
    
    // 不允许边界反弹
    self.collectView.bounces = NO;
    
    // 代理
    self.collectView.delegate = self;
    self.collectView.dataSource = self;

    // 注册表头区域
//    [self.collectView registerClass:[WJYRadioCollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header"];
    // 注册cell
    [self.collectView registerClass:[WJYRadioCollectionViewCell class] forCellWithReuseIdentifier:@"WJYRadioCollectionViewCell"];
    
    
    [self addSubview:self.collectView];
    
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 3;
}

#pragma mark CollectionViewCell
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    WJYRadioCollectionViewCell *radioCollectionViewCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"WJYRadioCollectionViewCell" forIndexPath:indexPath];
    
    radioCollectionViewCell.radioMdoel = self.radioArray[indexPath.row];
    
    radioCollectionViewCell.backgroundColor = [UIColor whiteColor];
    return radioCollectionViewCell;
    
}

//- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
//
// 
//    WJYRadioCollectionReusableView *headView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header" forIndexPath:indexPath];
//    headView.backgroundColor = [UIColor yellowColor];
//    
//    WJYRadioModel *radioM = [[WJYRadioModel alloc]init];
//    
//    radioM = self.radioTitleArray[indexPath.section];
//    headView.radioModel = self.radioTitleArray[indexPath.section];
//    NSLog(@"++++++++++%ld", (long)indexPath.section);
//    return headView;
//
//}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
